/*
*  Impp - Instant Messenger
*
*  Copyright (C) 2008  Oliver Schneider
*
*  This program is free software; you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation; either version 2 of the License, or
*  (at your option) any later version.
*
*  This program is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  You should have received a copy of the GNU General Public License
*  along with this program; if not, write to the Free Software
*  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/
#ifndef CLIPACKAGE_H_
#define CLIPACKAGE_H_

#include "PackageUtils.h"
#include <vector>
#include <wx/mstream.h>
#include <wx/datstrm.h>

namespace Impp {


class CliPackage
{
private:
	//std::vector<byte> data;
	wxMemoryOutputStream mem;
	wxDataOutputStream data;
	
public:
	CliPackage();
	virtual ~CliPackage();
	
	unsigned int size();
	byte* getData();
	void print(std::ostream & out);
	wxMemoryOutputStream* getOutputStream();
	
public:
	void writeByte(byte b);
	void writeWord(word w);
	void writeDWord(dword dw);
	void writeQWord(qword qw);
	
	void writeData(byte* d, size_t size);
	void writeString(const char* value, word lng);
	void writeString(const wxString & str);
	void writeStringUTF8(const wxString & str);
	word getUTF8StringLng(const wxString & str);
	void writeStringUTF16BE(const wxString & str);
	word getUTF16BEStringLng(const wxString & str);
	
    void writeSnacHeader(word service, word subtype,word flags,dword requestId);
	void writeTlv(word type, char* value, word valueLng);
	void writeTlv(word type, CliPackage & data);
	void writeTlvString(word type,const wxString & value);
	void writeTlvData(word type, byte* value, word valueLng);
	void writeTlvWord(word type, word data);
	void writeTlvByte(word type, byte data);
	void writeTlvEmpty(word type);
	void writeSsiItem(Item* item);
	
	
	void setBigEndianOrdered(bool be);
	

};

}

#endif /*CLIPACKAGE_H_*/
